Let's talk about the binary algorithm in the computer:
IntegerWe should be familiar with the binary algorithm of integers, that is, dividing them by two to get the remainder, and then sorting the remainder in reverse order. For example, calculate
Original optimizing garbage collection in Unity games. Here is a rough translation of this article, as your own notes.
Garbage collector is translated into a noun GC here. For garbage collection This translates into a verb memory recovery.
Original URL: http://blog.sina.com.cn/s/blog_827d041701017ctm.htmlQuestions raised: 12.0f-11.9f=0.10000038, "Lose The Endless" why?An explanation from MSDN:Http://msdn.microsoft.com/zh-cn/c151dt3s.aspxWhy floating-point numbers may lose precision
The two mechanism in the storage format is converted to floating-point numbers:Floating-point variables occupy 4 bytes (4 byte) in computer memory, i.e., 32-bit, a floating-point number consists of 2 parts: base m and exponent e;Base section: The
Questions raised: 12.0f-11.9f=0.10000038, "Lose The Endless" why?Now let's analyze in detail why a floating point operation causes loss of precision.1, Decimal binary representation problemFirst of all, we need to figure out the following two
Sorry, I used such a "two" question, but I hope the content is not too much.Actually, those who have learned programming are not familiar with these three things. Int is also called an integer. In. net, it refers to int32, which is a 32-bit signed
Question: 12.0f-11.9f = 0.10000038, why?
Now let's take a closer look at why floating point operations cause loss of precision?
1. binary representation of decimals
First, we need to clarify the following two problems:
(1) how to convert a
1. ScopeThe float and double ranges are determined by the number of digits of the index.The float index has eight digits, while the double index has 11 digits. The distribution is as follows:Float:1bit (symbol bit) 8 bits (index bit) 23 bits (tail
IEEE754 Standard, floating-point memory layoutThe following is only described by float (4 bytes in memory, 32bits), double (8 bytes, 64bits) in the same vein, only slightly different.The memory distribution of floatIEEE754 Specifies that 32bit float
Storage Methods of float and double in memory,
This article reproduced in: http://wenku.baidu.com/link? Url = Response
In C, float and double types are used for data of the floating point type. float data occupies 32 bits and double data.
64bit: How
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.